/* freerdp2.vapi
 *
 * Copyright 2022 Marc-André Lureau <marcandre.lureau@redhat.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial
 * portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 * Authors:
 *  Marc-André Lureau <marcandre.lureau@redhat.com>
 */

[CCode (cprefix = "freerdp_", lower_case_cprefix = "freerdp_", cheader_filename = "freerdp/freerdp.h")]
namespace FreeRDP {
	[CCode (cname = "UINT32", cprefix = "ERRINFO_", has_type_id = false)]
	enum ErrorInfo {
		SUCCESS,
		NONE,

		// Protocol-independent codes
		RPC_INITIATED_DISCONNECT,
		RPC_INITIATED_LOGOFF,
		IDLE_TIMEOUT,
		LOGON_TIMEOUT,
		DISCONNECTED_BY_OTHER_CONNECTION,
		OUT_OF_MEMORY,
		SERVER_DENIED_CONNECTION,
		SERVER_INSUFFICIENT_PRIVILEGES,
		SERVER_FRESH_CREDENTIALS_REQUIRED,
		RPC_INITIATED_DISCONNECT_BY_USER,
		LOGOFF_BY_USER,
		CLOSE_STACK_ON_DRIVER_NOT_READY,
		SERVER_DWM_CRASH,
		CLOSE_STACK_ON_DRIVER_FAILURE,
		CLOSE_STACK_ON_DRIVER_IFACE_FAILURE,
		SERVER_WINLOGON_CRASH,
		SERVER_CSRSS_CRASH,

		// Protocol-independent licensing codes
		LICENSE_INTERNAL,
		LICENSE_NO_LICENSE_SERVER,
		LICENSE_NO_LICENSE,
		LICENSE_BAD_CLIENT_MSG,
		LICENSE_HWID_DOESNT_MATCH_LICENSE,
		LICENSE_BAD_CLIENT_LICENSE,
		LICENSE_CANT_FINISH_PROTOCOL,
		LICENSE_CLIENT_ENDED_PROTOCOL,
		LICENSE_BAD_CLIENT_ENCRYPTION,
		LICENSE_CANT_UPGRADE_LICENSE,
		LICENSE_NO_REMOTE_CONNECTIONS,

		// Protocol-independent codes generated by the Connection Broker
		CB_DESTINATION_NOT_FOUND,
		CB_LOADING_DESTINATION,
		CB_REDIRECTING_TO_DESTINATION,
		CB_SESSION_ONLINE_VM_WAKE,
		CB_SESSION_ONLINE_VM_BOOT,
		CB_SESSION_ONLINE_VM_NO_DNS,
		CB_DESTINATION_POOL_NOT_FREE,
		CB_CONNECTION_CANCELLED,
		CB_CONNECTION_ERROR_INVALID_SETTINGS,
		CB_SESSION_ONLINE_VM_BOOT_TIMEOUT,
		CB_SESSION_ONLINE_VM_SESSMON_FAILED,

		// RDP specific codes
		UNKNOWN_DATA_PDU_TYPE,
		UNKNOWN_PDU_TYPE,
		DATA_PDU_SEQUENCE,
		CONTROL_PDU_SEQUENCE,
		INVALID_CONTROL_PDU_ACTION,
		INVALID_INPUT_PDU_TYPE,
		INVALID_INPUT_PDU_MOUSE,
		INVALID_REFRESH_RECT_PDU,
		CREATE_USER_DATA_FAILED,
		CONNECT_FAILED,
		CONFIRM_ACTIVE_HAS_WRONG_SHAREID,
		CONFIRM_ACTIVE_HAS_WRONG_ORIGINATOR,
		PERSISTENT_KEY_PDU_BAD_LENGTH,
		PERSISTENT_KEY_PDU_ILLEGAL_FIRST,
		PERSISTENT_KEY_PDU_TOO_MANY_TOTAL_KEYS,
		PERSISTENT_KEY_PDU_TOO_MANY_CACHE_KEYS,
		INPUT_PDU_BAD_LENGTH,
		BITMAP_CACHE_ERROR_PDU_BAD_LENGTH,
		SECURITY_DATA_TOO_SHORT,
		VCHANNEL_DATA_TOO_SHORT,
		SHARE_DATA_TOO_SHORT,
		BAD_SUPPRESS_OUTPUT_PDU,
		CONFIRM_ACTIVE_PDU_TOO_SHORT,
		CAPABILITY_SET_TOO_SMALL,
		CAPABILITY_SET_TOO_LARGE,
		NO_CURSOR_CACHE,
		BAD_CAPABILITIES,
		VIRTUAL_CHANNEL_DECOMPRESSION,
		INVALID_VC_COMPRESSION_TYPE,
		INVALID_CHANNEL_ID,
		VCHANNELS_TOO_MANY,
		REMOTEAPP_NOT_ENABLED,
		CACHE_CAP_NOT_SET,
		BITMAP_CACHE_ERROR_PDU_BAD_LENGTH2,
		OFFSCREEN_CACHE_ERROR_PDU_BAD_LENGTH,
		DRAWNINEGRID_CACHE_ERROR_PDU_BAD_LENGTH,
		GDIPLUS_PDU_BAD_LENGTH,
		SECURITY_DATA_TOO_SHORT2,
		SECURITY_DATA_TOO_SHORT3,
		SECURITY_DATA_TOO_SHORT4,
		SECURITY_DATA_TOO_SHORT5,
		SECURITY_DATA_TOO_SHORT6,
		SECURITY_DATA_TOO_SHORT7,
		SECURITY_DATA_TOO_SHORT8,
		SECURITY_DATA_TOO_SHORT9,
		SECURITY_DATA_TOO_SHORT10,
		SECURITY_DATA_TOO_SHORT11,
		SECURITY_DATA_TOO_SHORT12,
		SECURITY_DATA_TOO_SHORT13,
		SECURITY_DATA_TOO_SHORT14,
		SECURITY_DATA_TOO_SHORT15,
		SECURITY_DATA_TOO_SHORT16,
		SECURITY_DATA_TOO_SHORT17,
		SECURITY_DATA_TOO_SHORT18,
		SECURITY_DATA_TOO_SHORT19,
		SECURITY_DATA_TOO_SHORT20,
		SECURITY_DATA_TOO_SHORT21,
		SECURITY_DATA_TOO_SHORT22,
		SECURITY_DATA_TOO_SHORT23,
		BAD_MONITOR_DATA,
		VC_DECOMPRESSED_REASSEMBLE_FAILED,
		VC_DATA_TOO_LONG,
		BAD_FRAME_ACK_DATA,
		GRAPHICS_MODE_NOT_SUPPORTED,
		GRAPHICS_SUBSYSTEM_RESET_FAILED,
		GRAPHICS_SUBSYSTEM_FAILED,
		TIMEZONE_KEY_NAME_LENGTH_TOO_SHORT,
		TIMEZONE_KEY_NAME_LENGTH_TOO_LONG,
		DYNAMIC_DST_DISABLED_FIELD_MISSING,
		VC_DECODING_ERROR,
		VIRTUALDESKTOPTOOLARGE,
		MONITORGEOMETRYVALIDATIONFAILED,
		INVALIDMONITORCOUNT,
		UPDATE_SESSION_KEY_FAILED,
		DECRYPT_FAILED,
		ENCRYPT_FAILED,
		ENCRYPTION_PACKAGE_MISMATCH,
		DECRYPT_FAILED2,
		PEER_DISCONNECTED;

		[CCode (cname = "freerdp_get_error_info_string")]
		public unowned string? get_string ();

		[CCode (cname = "freerdp_get_error_info_name")]
		public unowned string? get_name ();

		[CCode (cname = "freerdp_get_error_info_category")]
		public unowned string? get_category ();
	}

	[CCode (cname = "UINT32", cprefix = "ERRBASE_", has_type_id = false)]
	enum ErrorBase {
		SUCCESS,
		NONE;

		[CCode (cname = "freerdp_get_error_base_string")]
		public unowned string? get_string ();

		[CCode (cname = "freerdp_get_error_base_name")]
		public unowned string? get_name ();

		[CCode (cname = "freerdp_get_error_base_category")]
		public unowned string? get_category ();
	}

	[CCode (cname = "UINT32", cprefix = "ERRCONNECT_", has_type_id = false)]
	enum ErrorConnect {
		SUCCESS,
		NONE,

		// Connection Error Codes
		PRE_CONNECT_FAILED,
		CONNECT_UNDEFINED,
		POST_CONNECT_FAILED,
		DNS_ERROR,
		DNS_NAME_NOT_FOUND,
		CONNECT_FAILED,
		MCS_CONNECT_INITIAL_ERROR,
		TLS_CONNECT_FAILED,
		AUTHENTICATION_FAILED,
		INSUFFICIENT_PRIVILEGES,
		CONNECT_CANCELLED,
		SECURITY_NEGO_CONNECT_FAILED,
		CONNECT_TRANSPORT_FAILED,
		PASSWORD_EXPIRED,

		// For non-domain workstation where we can't contact a kerberos server
		PASSWORD_CERTAINLY_EXPIRED,
		CLIENT_REVOKED,
		KDC_UNREACHABLE,

		ACCOUNT_DISABLED,
		PASSWORD_MUST_CHANGE,
		LOGON_FAILURE,
		WRONG_PASSWORD,
		ACCESS_DENIED,
		ACCOUNT_RESTRICTION,
		ACCOUNT_LOCKED_OUT,
		ACCOUNT_EXPIRED,
		LOGON_TYPE_NOT_GRANTED,
		NO_OR_MISSING_CREDENTIALS;

		[CCode (cname = "freerdp_get_error_connect_string")]
		public unowned string? get_string ();

		[CCode (cname = "freerdp_get_error_connect_name")]
		public unowned string? get_name ();

		[CCode (cname = "freerdp_get_error_connect_category")]
		public unowned string? get_category ();
	}

	[Compact]
	[CCode (cname = "struct rdp_settings", free_function = "freerdp_settings_free", copy_function = "freerdp_settings_clone", has_type_id = false)]
	public class Settings {
		[CCode (cname = "DWORD", cprefix = "FREERDP_SETTINGS_", has_type_id = false)]
		[Flags]
		public enum Flags {
			SERVER_MODE,
		}

		[CCode (cname = "int", cprefix = "PROXY_TYPE_", has_type_id = false)]
		public enum ProxyType {
			NONE,
			HTTP,
			SOCKS,
			IGNORE,
		}

		[CCode (cname = "int", cprefix = "RDP_SETTINGS_TYPE_", has_type_id = false)]
		public enum Type {
			BOOL,
			UINT16,
			INT16,
			UINT32,
			INT32,
			UINT64,
			INT64,
			STRING,
			POINTER,
		}

		[CCode (cname = "size_t", cprefix = "FreeRDP_", has_type_id = false)]
		public enum Id {
			instance,
			ServerMode,
			ShareId,
			PduSource,
			ServerPort,
			ServerHostname,
			Username,
			Password,
			Domain,
			PasswordHash,
			WaitForOutputBufferFlush,
			MaxTimeInCheckLoop,
			AcceptedCert,
			AcceptedCertLength,
			RdpVersion,
			DesktopWidth,
			DesktopHeight,
			ColorDepth,
			ConnectionType,
			ClientBuild,
			ClientHostname,
			ClientProductId,
			EarlyCapabilityFlags,
			NetworkAutoDetect,
			SupportAsymetricKeys,
			SupportErrorInfoPdu,
			SupportStatusInfoPdu,
			SupportMonitorLayoutPdu,
			SupportGraphicsPipeline,
			SupportDynamicTimeZone,
			SupportHeartbeatPdu,
			DesktopPhysicalWidth,
			DesktopPhysicalHeight,
			DesktopOrientation,
			DesktopScaleFactor,
			DeviceScaleFactor,
			UseRdpSecurityLayer,
			EncryptionMethods,
			ExtEncryptionMethods,
			EncryptionLevel,
			ServerRandom,
			ServerRandomLength,
			ServerCertificate,
			ServerCertificateLength,
			ClientRandom,
			ClientRandomLength,
			ChannelCount,
			ChannelDefArraySize,
			ChannelDefArray,
			ClusterInfoFlags,
			RedirectedSessionId,
			ConsoleSession,
			MonitorCount,
			MonitorDefArraySize,
			MonitorDefArray,
			SpanMonitors,
			UseMultimon,
			ForceMultimon,
			DesktopPosX,
			DesktopPosY,
			ListMonitors,
			MonitorIds,
			NumMonitorIds,
			MonitorLocalShiftX,
			MonitorLocalShiftY,
			HasMonitorAttributes,
			MultitransportFlags,
			SupportMultitransport,
			AlternateShell,
			ShellWorkingDirectory,
			AutoLogonEnabled,
			CompressionEnabled,
			DisableCtrlAltDel,
			EnableWindowsKey,
			MaximizeShell,
			LogonNotify,
			LogonErrors,
			MouseAttached,
			MouseHasWheel,
			RemoteConsoleAudio,
			AudioPlayback,
			AudioCapture,
			VideoDisable,
			PasswordIsSmartcardPin,
			UsingSavedCredentials,
			ForceEncryptedCsPdu,
			HiDefRemoteApp,
			CompressionLevel,
			IPv6Enabled,
			ClientAddress,
			ClientDir,
			AutoReconnectionEnabled,
			AutoReconnectMaxRetries,
			ClientAutoReconnectCookie,
			ServerAutoReconnectCookie,
			PrintReconnectCookie,
			ClientTimeZone,
			DynamicDSTTimeZoneKeyName,
			DynamicDaylightTimeDisabled,
			PerformanceFlags,
			AllowFontSmoothing,
			DisableWallpaper,
			DisableFullWindowDrag,
			DisableMenuAnims,
			DisableThemes,
			DisableCursorShadow,
			DisableCursorBlinking,
			AllowDesktopComposition,
			RemoteAssistanceMode,
			RemoteAssistanceSessionId,
			RemoteAssistancePassStub,
			RemoteAssistancePassword,
			RemoteAssistanceRCTicket,
			EncomspVirtualChannel,
			RemdeskVirtualChannel,
			LyncRdpMode,
			RemoteAssistanceRequestControl,
			TlsSecurity,
			NlaSecurity,
			RdpSecurity,
			ExtSecurity,
			Authentication,
			RequestedProtocols,
			SelectedProtocol,
			NegotiationFlags,
			NegotiateSecurityLayer,
			RestrictedAdminModeRequired,
			AuthenticationServiceClass,
			DisableCredentialsDelegation,
			AuthenticationLevel,
			AllowedTlsCiphers,
			VmConnectMode,
			NtlmSamFile,
			FIPSMode,
			TlsSecLevel,
			TLSMinVersion,
			TLSMaxVersion,
			MstscCookieMode,
			CookieMaxLength,
			PreconnectionId,
			PreconnectionBlob,
			SendPreconnectionPdu,
			RedirectionFlags,
			TargetNetAddress,
			LoadBalanceInfo,
			LoadBalanceInfoLength,
			RedirectionUsername,
			RedirectionDomain,
			RedirectionPassword,
			RedirectionPasswordLength,
			RedirectionTargetFQDN,
			RedirectionTargetNetBiosName,
			RedirectionTsvUrl,
			RedirectionTsvUrlLength,
			TargetNetAddressCount,
			TargetNetAddresses,
			TargetNetPorts,
			RedirectionAcceptedCert,
			RedirectionAcceptedCertLength,
			RedirectionPreferType,
			Password51,
			Password51Length,
			SmartcardLogon,
			PromptForCredentials,
			KerberosKdc,
			KerberosRealm,
			IgnoreCertificate,
			CertificateName,
			CertificateFile,
			PrivateKeyFile,
			RdpKeyFile,
			RdpServerRsaKey,
			RdpServerCertificate,
			ExternalCertificateManagement,
			CertificateContent,
			PrivateKeyContent,
			RdpKeyContent,
			AutoAcceptCertificate,
			AutoDenyCertificate,
			CertificateAcceptedFingerprints,
			Workarea,
			Fullscreen,
			PercentScreen,
			GrabKeyboard,
			Decorations,
			MouseMotion,
			WindowTitle,
			ParentWindowId,
			AsyncInput,
			AsyncUpdate,
			AsyncChannels,
			ToggleFullscreen,
			WmClass,
			EmbeddedWindow,
			SmartSizing,
			XPan,
			YPan,
			SmartSizingWidth,
			SmartSizingHeight,
			PercentScreenUseWidth,
			PercentScreenUseHeight,
			DynamicResolutionUpdate,
			SoftwareGdi,
			LocalConnection,
			AuthenticationOnly,
			CredentialsFromStdin,
			UnmapButtons,
			OldLicenseBehaviour,
			ComputerName,
			ConnectionFile,
			AssistanceFile,
			HomePath,
			ConfigPath,
			CurrentPath,
			DumpRemoteFx,
			PlayRemoteFx,
			DumpRemoteFxFile,
			PlayRemoteFxFile,
			GatewayUsageMethod,
			GatewayPort,
			GatewayHostname,
			GatewayUsername,
			GatewayPassword,
			GatewayDomain,
			GatewayCredentialsSource,
			GatewayUseSameCredentials,
			GatewayEnabled,
			GatewayBypassLocal,
			GatewayRpcTransport,
			GatewayHttpTransport,
			GatewayUdpTransport,
			GatewayAccessToken,
			GatewayAcceptedCert,
			GatewayAcceptedCertLength,
			GatewayHttpUseWebsockets,
			ProxyType,
			ProxyHostname,
			ProxyPort,
			ProxyUsername,
			ProxyPassword,
			RemoteApplicationMode,
			RemoteApplicationName,
			RemoteApplicationIcon,
			RemoteApplicationProgram,
			RemoteApplicationFile,
			RemoteApplicationGuid,
			RemoteApplicationCmdLine,
			RemoteApplicationExpandCmdLine,
			RemoteApplicationExpandWorkingDir,
			DisableRemoteAppCapsCheck,
			RemoteAppNumIconCaches,
			RemoteAppNumIconCacheEntries,
			RemoteAppLanguageBarSupported,
			RemoteWndSupportLevel,
			RemoteApplicationSupportLevel,
			RemoteApplicationSupportMask,
			RemoteApplicationWorkingDir,
			ReceivedCapabilities,
			ReceivedCapabilitiesSize,
			OsMajorType,
			OsMinorType,
			RefreshRect,
			SuppressOutput,
			FastPathOutput,
			SaltedChecksum,
			LongCredentialsSupported,
			NoBitmapCompressionHeader,
			BitmapCompressionDisabled,
			DesktopResize,
			DrawAllowDynamicColorFidelity,
			DrawAllowColorSubsampling,
			DrawAllowSkipAlpha,
			OrderSupport,
			BitmapCacheV3Enabled,
			AltSecFrameMarkerSupport,
			AllowUnanouncedOrdersFromServer,
			BitmapCacheEnabled,
			BitmapCacheVersion,
			AllowCacheWaitingList,
			BitmapCachePersistEnabled,
			BitmapCacheV2NumCells,
			BitmapCacheV2CellInfo,
			ColorPointerFlag,
			PointerCacheSize,
			KeyboardRemappingList,
			KeyboardCodePage,
			KeyboardLayout,
			KeyboardType,
			KeyboardSubType,
			KeyboardFunctionKey,
			ImeFileName,
			UnicodeInput,
			FastPathInput,
			MultiTouchInput,
			MultiTouchGestures,
			KeyboardHook,
			HasHorizontalWheel,
			HasExtendedMouseEvent,
			BrushSupportLevel,
			GlyphSupportLevel,
			GlyphCache,
			FragCache,
			OffscreenSupportLevel,
			OffscreenCacheSize,
			OffscreenCacheEntries,
			VirtualChannelCompressionFlags,
			VirtualChannelChunkSize,
			SoundBeepsEnabled,
			MultifragMaxRequestSize,
			LargePointerFlag,
			CompDeskSupportLevel,
			SurfaceCommandsEnabled,
			FrameMarkerCommandEnabled,
			SurfaceFrameMarkerEnabled,
			RemoteFxOnly,
			RemoteFxCodec,
			RemoteFxCodecId,
			RemoteFxCodecMode,
			RemoteFxImageCodec,
			RemoteFxCaptureFlags,
			NSCodec,
			NSCodecId,
			FrameAcknowledge,
			NSCodecColorLossLevel,
			NSCodecAllowSubsampling,
			NSCodecAllowDynamicColorFidelity,
			JpegCodec,
			JpegCodecId,
			JpegQuality,
			GfxThinClient,
			GfxSmallCache,
			GfxProgressive,
			GfxProgressiveV2,
			GfxH264,
			GfxAVC444,
			GfxSendQoeAck,
			GfxAVC444v2,
			GfxCapsFilter,
			BitmapCacheV3CodecId,
			DrawNineGridEnabled,
			DrawNineGridCacheSize,
			DrawNineGridCacheEntries,
			DrawGdiPlusEnabled,
			DrawGdiPlusCacheEnabled,
			DeviceRedirection,
			DeviceCount,
			DeviceArraySize,
			DeviceArray,
			RedirectDrives,
			RedirectHomeDrive,
			DrivesToRedirect,
			RedirectSmartCards,
			RedirectPrinters,
			RedirectSerialPorts,
			RedirectParallelPorts,
			PreferIPv6OverIPv4,
			RedirectClipboard,
			StaticChannelCount,
			StaticChannelArraySize,
			StaticChannelArray,
			DynamicChannelCount,
			DynamicChannelArraySize,
			DynamicChannelArray,
			SupportDynamicChannels,
			SupportEchoChannel,
			SupportDisplayControl,
			SupportGeometryTracking,
			SupportSSHAgentChannel,
			SupportVideoOptimized,
			RDP2TCPArgs,
			TcpKeepAlive,
			TcpKeepAliveRetries,
			TcpKeepAliveDelay,
			TcpKeepAliveInterval,
			TcpAckTimeout,
			TcpConnectTimeout,
		}

		[CCode (cname = "freerdp_settings_new")]
		public Settings (Flags flags);

		public bool get_bool (Id id);
		public bool set_bool (Id id, bool param);

		public int16 get_int16 (Id id);
		public bool set_int16 (Id id, int16 param);

		public uint16 get_uint16 (Id id);
		public bool set_uint16 (Id id, uint16 param);

		public int32 get_int32 (Id id);
		public bool set_int32 (Id id, int32 param);

		public uint32 get_uint32 (Id id);
		public bool set_uint32 (Id id, uint32 param);

		public int64 get_int64 (Id id);
		public bool set_int64 (Id id, int64 param);

		public uint64 get_uint64 (Id id);
		public bool set_uint64 (Id id, uint64 param);

		public unowned string? get_string (Id id);
		public bool set_string (Id id, string param);

		public bool set_value_for_name (string name, string value);

		public static Id get_key_for_name (string name);
		public static Type get_type_for_name (string name);
		public static Type get_type_for_key (Id id);
		public static unowned string? get_name_for_key (Id id);
	}
}
